package com.liqiye.paymanager.controller;

import com.liqiye.paymanager.bean.common.IpLocation;
import com.liqiye.paymanager.service.evaluate.IpLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 风控接口
 */

@RestController
@RequestMapping("/evaluate")
public class EvaluateController {

    @Autowired
    private IpLocationService ipLocationService;

    /**
     * 查找ip位置信息
     */
    @GetMapping("/lookup")
    public IpLocation lookup(@RequestParam String ip) {
        return ipLocationService.lookup(ip);
    }

    /**
     * 根据ip实现风控过滤，或者ip黑名单记录
     */
    @GetMapping("/filter")
    public ResponseEntity<?> filter(@RequestParam String ip) {
        ipLocationService.filter(ip);
        return ResponseEntity.ok("success");
    }

}
